import java.util.Scanner;

public class Demo {
   public static Object object = new Object();

    public static void main(String[] args) {

        Thread t = new Thread(()->{
            synchronized(object) {
                System.out.println("wait开始!");
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out. println("wait结束!");
            }

        });
        t.start();

        Thread t1 = new Thread(()->{
            synchronized(object) {
                Scanner scanner = new Scanner(System.in);
                System.out.println("输入内容来进行通知:");
                scanner.next();
                System.out.println("notify开始");
                object.notify();
                System.out.println("notify结束");
            }
        });

        t1.start();
    }
}
